package com.demo.supplier.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 用户创建/更新DTO
 * 
 * @author demo
 */
@Data
@ApiModel("用户创建/更新DTO")
public class UserDto {

    /**
     * 校验分组：创建/更新
     */
    public interface Create {}
    public interface Update {}

    @ApiModelProperty("用户ID（更新时需要）")
    private Long id;

    @ApiModelProperty(value = "用户名", required = true)
    @NotBlank(message = "用户名不能为空", groups = {Create.class, Update.class})
    @Size(min = 3, max = 50, message = "用户名长度必须在3-50个字符之间", groups = {Create.class, Update.class})
    private String username;

    @ApiModelProperty("密码（创建时必填，更新时可选）")
    @NotBlank(message = "密码不能为空", groups = {Create.class})
    @Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间", groups = {Create.class})
    private String password;

    @ApiModelProperty(value = "真实姓名", required = true)
    @NotBlank(message = "真实姓名不能为空", groups = {Create.class, Update.class})
    @Size(max = 50, message = "真实姓名长度不能超过50个字符", groups = {Create.class, Update.class})
    private String realName;

    @ApiModelProperty("邮箱")
    @Email(message = "邮箱格式不正确", groups = {Create.class, Update.class})
    @Size(max = 100, message = "邮箱长度不能超过100个字符", groups = {Create.class, Update.class})
    private String email;

    @ApiModelProperty("手机号")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确", groups = {Create.class, Update.class})
    private String phone;

    @ApiModelProperty("状态：1=启用，0=禁用")
    private Integer status;

    @ApiModelProperty("头像文件ID")
    private Long avatarFileId;
}